package cn.dt70.controller;

import cn.dt70.pojo.AqbMsgcontent;
import cn.dt70.pojo.AqbUser;
import cn.dt70.pojo.AqbUserMsg;
import cn.dt70.service.AqbMsgcontentService;
import cn.dt70.service.AqbUserMsgService;
import cn.dt70.utils.Constants;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/test/")
public class TestController {
    @Resource
    private AqbMsgcontentService aqbMsgcontentService;
    @Resource
    private AqbUserMsgService aqbUserMsgService;

    @RequestMapping("add")
    @ResponseBody
    public void add(HttpSession session){
        AqbMsgcontent aqbMsgcontent=new AqbMsgcontent();
        aqbMsgcontent.setContent("1234");
        aqbMsgcontentService.insertRetrunId(aqbMsgcontent);
        AqbUserMsg aqbUserMsg=new AqbUserMsg();
        aqbUserMsg.setMessageID(aqbMsgcontent.getId());
        AqbUser aqbUser=(AqbUser)session.getAttribute(Constants.USER_SESSION);
        aqbUserMsg.setRecID(aqbUser.getUserId());
        aqbUserMsgService.add(aqbUserMsg);
    }
}
